const input = ['# a', '## b', '## c', '### d', '# e']

const getOutPut = (input) => {
    let hn = ''
    return input.reduce((res, cur) => {
        const [symbol, title] = cur.split(' ')
        if (hn) {
            const hnList = hn.split('.')
            console.log(symbol, hnList)
            if (symbol.length < hnList.length) {
                hn = '' + (+hnList[0] + 1)
            } else if (symbol.length > hnList.length) {
                hn += '.1'
            } else {
                const last = hnList.pop()
                hn = hnList.join('.') + '.' + (+last + 1)
            }
        } else {
            hn = '1'
        }
        res.push({ hn, title })
        return res
    }, [])
}

// console.log(getOutPut(input))


// const promise = new Promise((resolve, reject) => {
//     console.log(1)
//     resolve()
//     console.log(2)
// })

// promise.then(() => {
//     console.log(3)
// })

// console.log(4)

Promise.resolve(1).then(2).then(Promise.resolve(3)).then(console.log)